﻿using System;
using System.Text;

using NetStsAdm.Commands;

namespace NetStsAdm
{
    public class Program
    {        
        static void Main(string[] args)
        {
            Command cmd = null;
            Console.WriteLine();
            try
            {
                cmd = new Command(Command.ParseArgs(args));
            }
            catch (ArgumentException)
            {
                Console.WriteLine(Resource.CMD_INVALID);
                Console.WriteLine();
                Console.WriteLine(HelpCommand.GetHelp());
            }
            catch (Exception)
            {
                Console.WriteLine(Resource.ERROR_UNSPECIFIED);
            }

            if (cmd != null)
            {
                string output = "";
                int result = cmd.Execute(out output);

                // Handle return value!
                switch (result)
                {
                    case 0:
                        Console.WriteLine(output);
                        break;
                    case -1:
                        Console.WriteLine(Resource.ERROR_OCCURED);
                        Console.WriteLine();
                        Console.WriteLine(output);
                        break;
                    case -2:
                        Console.WriteLine(Resource.CMD_INVALID);
                        Console.WriteLine();
                        Console.WriteLine(HelpCommand.GetHelp());
                        break;
                }

                Console.WriteLine();
            }
        }
    }
}
